require 'test/unit'
require 'lib/smppclient/pdu/unbind'
require 'lib/smppclient/util/byte_buffer'

class TestUnbind < MiniTest::Unit::TestCase

  include SmppClient::Pdu
  include SmppClient::Util

  def test_bytes_to_object
    bb = ByteBuffer.new
    bb.append_int(16)
    bb.append_int(0x00000006)
    bb.append_int(0)
    bb.append_int(1000123456)

    unbind = Unbind.new(bb)
    assert_equal(16, unbind.command_length)
    assert_equal(CommandId::UNBIND, unbind.command_id)
    assert_equal(CommandStatus::ESME_ROK, unbind.command_status)
    assert_equal(1000123456, unbind.sequence_number)
  end

  def test_object_to_bytes
    unbind = Unbind.new
    assert_equal(Pdu::HEADER_LENGTH, unbind.command_length)
    assert_equal(CommandId::UNBIND, unbind.command_id)
    assert_equal(CommandStatus::ESME_ROK, unbind.command_status)
    assert_equal(0, unbind.sequence_number)
    assert_equal('00000010000000060000000000000000', unbind.buffer.to_s)
  end

end